<template>
  <div class="patient-card" @click="handleCilckToDetails">
    <div class="card-head">
      <div style="display: flex; align-items: center">
        <span style="font-size: 1.8vw">{{ info.bedName }}</span>
        &emsp;
        <span v-if="info.ptnName" style="font-size: 1.2vw">{{ info.ptnName }}</span>
      </div>
      <span v-if="info.nurLevel" class="level" style="background: #f00">{{
        info.nurLevel
      }}</span>
      <span
        class="disease"
        :style="{
          background: '#785da8',
          visibility: info.serious ? 'visible' : 'hidden',
        }"
        >{{ info.serious }}</span
      >
    </div>
    <div class="card-content" v-if="info.adTime">
      <div style="color: #777777">
        <span>{{ info.sex }}</span
        >&nbsp;<span>{{ info.age }}岁</span>
      </div>
      <div style="color: #777777; display: flex; justify-content: space-between">
        <span>住院号：{{ info.hospitalNo }}</span
        ><span>天数：{{ info.inHospitalDays }}</span>
      </div>
      <div style="color: #777777">入院日期：{{ info.adTime }}</div>
      <div><span class="doctor">主</span>&emsp;<span>李*</span></div>
      <div class="pulse-oxygen">
        <div>
          <div>
            <img src="../../../assets/images/pulse-icon.svg" alt="" />
            <div>脉搏&emsp14;(次/分)</div>
          </div>
          <div class="value">{{ info.pulse || "--" }}</div>
        </div>
        <div>
          <div>
            <img src="../../../assets/images/bloodOxygen-icon.svg" alt="" />
            <div>血氧&emsp14;(%)</div>
          </div>
          <div class="value">{{ info.xueYang || "--" }}</div>
        </div>
      </div>
      <div class="temperature-pressure">
        <div>
          <div>
            <img src="../../../assets/images/temperature-icon.svg" alt="" />
            <div>体温&emsp14;(℃)</div>
          </div>
          <div class="value">{{ info.tempe || "--" }}</div>
        </div>
        <div>
          <div>
            <img src="../../../assets/images/bloodPressure-icon.svg" alt="" />
            <div>血压&emsp14;(mmhg)</div>
          </div>
          <div class="value">{{ info.xueya || "--" }}</div>
        </div>
      </div>
    </div>
    <div
      style="
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
        min-height: 22vh;
      "
      v-else
    >
      <img :src="emptyBed" alt="" />
    </div>
  </div>
</template>

<script setup>
import emptyBed from "@/assets/images/empty-bed.svg";
import { useRouter } from "vue-router";

const router = useRouter();

const props = defineProps({
  info: {
    type: Object,
    default: () => ({}),
  },
});

// let days = computed(() => {
//   let timeStamp = new Date() - new Date("2024-07-30");
//   return Math.ceil(timeStamp / 1000 / 60 / 60 / 24);
// });

//查看病人详情(将住院号发送到详情页，用于查询病人详情)
function handleCilckToDetails() {
  let keys = Object.keys(props.info);
  if (keys.length < 2) return;
  router.push({
    path: "/patientDetails",
    query: { hospitalNo: props.info.hospitalNo },
  });
}
</script>

<style lang="scss" scoped>
.patient-card {
  border-radius: 10px;
  background: #fff;
  padding: 1vw;
  display: flex;
  flex-direction: column;
  .card-content {
    > div {
      margin-bottom: 1vh;
    }
    > div:last-child {
      margin-bottom: 0;
    }
  }
  .card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1vh;
    .level {
      display: block;
      padding: 5px 10px;
      color: #fff;
      font-weight: 550;
      border-radius: 1vw;
    }
    .disease {
      color: #fff;
      padding: 5px 8px;
      border-radius: 50%;
    }
  }
  .pulse-oxygen {
    display: flex;
    justify-content: space-between;

    > div {
      flex: 1;
      background: #efefef;
      display: flex;
      justify-content: space-between;
      padding: 0.5vh 0.5vw;
    }
    > div:first-child {
      margin-right: 1.5vw;
    }
  }
  .temperature-pressure {
    display: flex;
    justify-content: space-between;

    > div {
      flex: 1;
      background: #efefef;
      display: flex;
      justify-content: space-between;
      padding: 0.5vh 0.5vw;
    }
    > div:first-child {
      margin-right: 1.5vw;
    }
  }
  .value {
    display: flex;
    align-items: center;
  }
  .doctor {
    display: inline-block;
    width: 1.2vw;
    height: 1.2vw;
    text-align: center;
    line-height: 1.2vw;
    background: #0860db;
    color: #fff;
    font-weight: 600;
    border-radius: 3px;
  }
}
</style>
